import type {NextPage}from 'next'
import {useState} from 'react'
import Link from 'next/link'
import {navs} from './config'
import styles from './index.module.scss'
import Login from '@/components/Login'
import {useRouter} from "next/router";

const Navbar:NextPage=()=>{
const {pathname} = useRouter()
    const handleGoToEditorPage = ()=>{
        console.log('handleGoToEditorPage')
        console.log(pathname)
    }

    const [isShowLogin,setIsShowLogin] = useState(false)
    const handleLogin = ()=>{
        setIsShowLogin(true)
    }
    const handleClose = ()=>{
        setIsShowLogin(false)
    }
    return (
        <div className={styles.navbar}>
            <section className={styles.logArea}>BLOG-C</section>
            <section className={styles.linkArea}>
                {
                    navs?.map(nav=>(
                        <Link key={nav?.label} href={nav?.value} legacyBehavior={true}>
                            <a>{nav?.label}</a>
                        </Link>
                    ))
                }
            </section>
            <section onClick={handleGoToEditorPage}>
                写文章
            </section>
            <section onClick={handleLogin}>
                登录
            </section>
            <Login isShow={isShowLogin} onClose={handleClose}/>
        </div>
    )
}
export default Navbar
